/**
 * @param {number[]} nums
 * @param {number} target
 * @return {number[]}
 */
var twoSum = function (nums, target) {
  let j,
    len = nums.length;
  let hash = {};
  for (let i = 0; i < len; i++) {
    j = target - nums[i];
    if (hash[j] !== undefined) {
      return [i, hash[j]];
    } else {
      hash[nums[i]] = i;
    }
  }
};
